package my.graphics.sample;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.Path.Direction;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.shapes.OvalShape;
import android.graphics.drawable.shapes.Shape;
import android.os.Bundle;
import android.view.View;

public class Circle_Solution2_View extends Activity {
	private Circle circle;
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        circle = new Circle(this);
        setContentView(circle);
    }
	
	private static class Circle extends View{
		private ShapeDrawable mShape;
		private static class CircleShapeDrawable extends ShapeDrawable{
			private Paint mStrokePaint = new Paint();

            public CircleShapeDrawable(Shape s) {
                super(s);
                mStrokePaint.setStyle(Paint.Style.FILL_AND_STROKE);
            }

            @Override protected void onDraw(Shape s, Canvas c, Paint p) {
                s.draw(c, p);
                s.draw(c, mStrokePaint);
            }
		}
		public Circle(Context context) {
			super(context);
			mShape = new ShapeDrawable(new OvalShape());
		}
		
		@Override protected void onDraw(Canvas canvas) {
			int x = 150;
            int y = 150;
            int radius = 50;
            int width = 120;
            int height = 120;
            mShape.setBounds(x, y, x + width, y + height);
            mShape.getPaint().setColor(Color.YELLOW);
            mShape.getPaint().setStrokeWidth(9);
			//mShape.draw(canvas);
            Path path = new Path();
            path.addCircle(x, y, radius, Direction.CW);
            canvas.drawPath(path, mShape.getPaint());
            canvas.drawTextOnPath("In God, we trust", path, 0, 20, mShape.getPaint());
            mShape.getPaint().setColor(Color.RED);
            canvas.drawCircle(x, y, radius - 10, mShape.getPaint());
	    }
	}
}
